#pragma once
#include "afxwin.h"
//-------------------------------------------------------------------------------------------------
//FileNewDlg.h  - Create New IDF dialog         
//-------------------------------------------------------------------------------------------------
//FreeBSD License
//Copyright 2011 Will Stott All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
//   1. Redistributions of source code must retain the above copyright notice, this list of
//      conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice, this list
//      of conditions and the following disclaimer in the documentation and/or other materials
//      provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY Will Stott ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Will Stott OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of Will Stott.
//
//----Authors--------------------------------------------------------------------------------------
//created by: will.stott@ucl.ac.uk Nov 2011
//
//----Comments-------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------

#include "ImageProcLib.h"
#include "ImageDataset.h"

class FileNewDlg : public CDialogEx
{
	DECLARE_DYNAMIC(FileNewDlg)

public:
	FileNewDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~FileNewDlg();
//
	static const int IMAGESRC_FILESYS = 0;
	static const int IMAGESRC_REMOTE_DB = 2;
	static const int IMAGESRC_LOCAL_DB = 1;
	static const int HEADER_STD = 0;
	static const int HEADER_COPYFROM = 1;
	static const int HEADER_CUSTOM = 2;

// Dialog Data
	enum { IDD = IDD_FILENEW };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	CString m_IDFName;
	CString m_IDFOwner;
	CComboBox m_StdHeaderCombo;
	CString m_IDFDescription;
	CString m_IDFVersion;
	CString m_IDFRepository;

	CString m_ImageDatasetFile;
	CString m_DataDir;
	CString m_ImportImagesDir;
	CString m_LocalDbConnectionStr;
	CString m_RemoteDbConnectionStr;
	CString m_SQLStatementFile;
	CString m_Results;
	int m_ImageSource;
	int m_HeaderType;
	CButton m_CustomHeaderButton;


	afx_msg void OnBnClickedDatasetDirBrowseButton();
	afx_msg void OnBnClickedImportFileSystemBrowseButton();
	afx_msg void OnBnClickedSqlStatementFileBrowseButton();
	afx_msg void OnBnClickedSqlStatementFileViewButton();
	afx_msg void OnBnClickedOk();
	virtual BOOL OnInitDialog();

	afx_msg void OnBnClickedDefineHeaderButton();
	afx_msg void OnBnClickedIdfViewButton();
	afx_msg void OnBnClickedHeaderTypeRadio();
	afx_msg void OnBnClickedTemplatebrowsebutton();
	afx_msg void OnBnClickedImageSourceRadio();

	CString GetIDFPathFilename();
	CString GetDataDir();


private:
	bool	CreateImageDataSetFromFileSystem(ImageDataset &idf);
	bool	CreateImageDataSetFromDb(ImageDataset &idf);
	void	OutputResultMsg(LPCSTR msg1, LPCSTR msg2=NULL);
	void	ClearOutputResultMsg();
	CString GetDataDirBackslash();
	
public:

	CButton m_BrowseImageSourceFiles;
	CButton m_SQLStatementFileBrowseCtrl;
	CButton m_SQLStatementFileViewCtrl;
	CEdit m_ImageSourceFileCtrl;
	CEdit m_SQLStatementFileCtrl;
	CEdit m_ImageSourceDbLocalCtrl;
	CEdit m_ImageSourceDbRemoteCtrl;
	CButton m_HeaderCopyFromBrowse;
};

//-------------------------------------------------------------------------------------------------
//			E N D   O F   F I L E
//-------------------------------------------------------------------------------------------------

